package com.labofjet.message;

import java.text.MessageFormat;

import com.labofjet.spring.common.SpringContextUtils;

public class MessageUtils {
    private static final IMessageSource SOURCE = SpringContextUtils.getBean(IMessageSource.class);

    private MessageUtils() {

    }

    /**
     * 通过代码获取message
     * @param code
     * @return
     */
    public static String getMessage(String code) {
        return SOURCE.getMessage(code);
    }

    /**
     * 把传入的参数插入到{0}等占位符中
     * @param code
     * @param param
     * @return
     */
    public static String getMessage(String code, Object... param) {
        return MessageFormat.format(SOURCE.getMessage(code), param);
    }
}
